
import { reactive} from 'vue';
import {useRouter} from "vue-router";
const router = useRouter()
interface FormState {
    username: string;
    password: string;
    remember: boolean;
  }
export const formState = reactive<FormState>({
    username: '16637142550',
    password: '123456',
    remember: true,
  });
export let validateusername = async (_rule: any, value: any) => {
    if (value === '') {
      return Promise.reject('请输入用户名');
    }
    else if(!/^1[3-9]\d{9}$/.test(value)){
         return Promise.reject("格式有误")
    }else{
      return Promise.resolve()
    }
  };
  export let validateuserpassword = async (_rule: any, value: string) => {
    if (value === '') {
      return Promise.reject('请输入密码');
    } 
    else if(!/^\w{6,12}$/.test(value)){
            return Promise.reject('请输入6-12位的密码')
    }
    else {
     
      return Promise.resolve();
    }
  }

  
  // export const onFinish = (values: any) => {
  //   console.log('Success:', values);
  //   // axios.post('https://d33a5037-6c63-4e92-8bb1-30018ab701ea.bspapp.com/http/admin/user/login',values).then((res)=>{
  //   //   console.log(res)
  //   // })
  //   logonjk(values).then((res)=>{
  //    console.log(res)
  //     if(res.data.code==0){
  //       message.success(res.data.msg);
  //       LoginLocalStorage(res.data)
  //       console.log(router)
  //       router.replace('/')
  //   }else{
  //       message.error(res.data.msg);
       
  //   }
  //   })
  //   .catch((error)=>{
  //     console.log(error)
  //   })
  // };
 
  export const onFinishFailed = (errorInfo: any) => {
    console.log('Failed:', errorInfo);
  }; 
  
  